package memory.GUI;

import java.awt.*;
import javax.swing.*;
import memory.*;

/**
 *
 * @author Scott Robinson
 */
public class MainFrame extends JFrame {


    //private final int HEIGHT = 730;
    //private final int WIDTH = 630;

    private Board b;
    private MemoryBoardPanel mbp;
    private Controller controller;
    private ControlPanel controlPanel;
    private final int SQUARE_SIZE = 70;
    private final int BORDER_SIZE = 1;
    private final int SPACING_SIZE = 10;



    public MainFrame (String title, int rows, int columns, SizePrompt sp, GameDifficulty gd) {
        super (title);
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        }
        b = new Board(rows,columns);
        mbp = new MemoryBoardPanel(b);
        controlPanel = new ControlPanel();
        controller = new Controller(mbp, b, this, controlPanel, sp, gd);

        setLayout(new BorderLayout());
        add(mbp, BorderLayout.CENTER);
        add (controlPanel, BorderLayout.SOUTH);        
        setSize(columns * SQUARE_SIZE + columns * BORDER_SIZE * 2 + (columns - 1) * SPACING_SIZE ,
                rows * SQUARE_SIZE + rows * BORDER_SIZE * 2 + (rows - 1) * SPACING_SIZE + 89);

        setLocation(Toolkit.getDefaultToolkit ().getScreenSize().width / 2 - this.getWidth() / 2,
                Toolkit.getDefaultToolkit ().getScreenSize().height / 2 - this.getHeight() / 2);

//        for ( SquarePanel spl [] : mbp.getAllSquares() ) {
//            for (SquarePanel s : spl) {
//                setContentPane(s);
//            }
//        }

    }

    public ControlPanel getControlPanel() {
        return controlPanel;
    }

    public MemoryBoardPanel getMbp() {
        return mbp;
    }

}
